/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.edu.assunto;

import br.edu.disciplina.Disciplina;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

/**
 *
 * @author 'Pedro
 */
@Entity
public class Assunto implements Serializable, Comparable<Assunto>{
    
    @Id
    @GeneratedValue
    private int id;
    
    private String desccricao;
    
    @ManyToOne
    private Disciplina disciplina;

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * @return the desccricao
     */
    public String getDesccricao() {
        return desccricao;
    }

    /**
     * @param desccricao the desccricao to set
     */
    public void setDesccricao(String desccricao) {
        this.desccricao = desccricao;
    }

    /**
     * @return the disciplina
     */
    public Disciplina getDisciplina() {
        return disciplina;
    }

    /**
     * @param disciplina the disciplina to set
     */
    public void setDisciplina(Disciplina disciplina) {
        this.disciplina = disciplina;
    }

    @Override
    public int compareTo(Assunto t) {
        return disciplina.compareTo(t.disciplina);
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 79 * hash + this.id;
        hash = 79 * hash + Objects.hashCode(this.desccricao);
        hash = 79 * hash + Objects.hashCode(this.disciplina);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Assunto other = (Assunto) obj;
        if (this.id != other.id) {
            return false;
        }
        if (!Objects.equals(this.desccricao, other.desccricao)) {
            return false;
        }
        if (!Objects.equals(this.disciplina, other.disciplina)) {
            return false;
        }
        return true;
    }
    
    public String toString(){
        return desccricao;
    }
    
}
